package com.rfs.design.templatemethod;

import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
* @author: rfs
* @create: 2023/5/22
* @description: 购物车工厂
**/
@Component
public class CartFactory {
    @Resource
    private List<AbstractCart> cartList;
    public AbstractCart getCart(CartTypeEnum cartTypeEnum){
        return cartList.stream().filter(m-> Objects.equals(m.getCartType(),cartTypeEnum))
                .findFirst()
                .get();
    }
}
